<?php
/**
把在product表里latest值为1 的查出来 显示
 */
namespace Admin\Controller;
use Think\Controller;
header("Content-Type:text/html;charset=utf-8");
Class SizeController extends Controller{

    Public function index(){
        $this->siz = M('size')->select();
        $this->display();
    }

    Public function add(){

        $siz = M('size')->order('id desc')->limit(1)->field('sid')->select();
        $this->assign('Nowsid',$siz['0']['sid']+1);

        if ($_POST['submit']=='提交'){
            $Validation = new \Admin\Model\ValidationModel();
            if ($res = $Validation->validation($_POST['size'],'null')){
                $this->error($res);
            }
            $data = array(
                /*
                    此处有个大bug 使sid与id不一致
                 */
                'size' => $_POST['size'],
                'sid' => $siz['0']['sid']+1,
            );
            if ($pd = M('size')->data($data)->add()){
                $this->success('添加成功!');
            }
        }else{
            $this->display();
        }

    }
}
?>